<template>
  <div class="popmenu">
    <div class="newText">流行菜单</div>
    <div class="all" @click="liuxing">全部</div>
    <div class="popbox">

      <div v-for="(item, index) in title1" class="pbox" :data-cookid='title1[index]'>
        <img :src="img1[index]" alt="" class="img" @click="myselect"/>

        <div class="title1" @click="myselect">{{ item }}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      title1: [],
      img1: [],
    };
  },
  async mounted() {
    var img1 = [];
    var title1 = [];
    this.$axios("/zztz/popmenu").then((res) => {
      res.data.map((el) => {
        title1.push(el.classer);
      });
      this.title1 = title1;
    });
    this.$axios("/zztz/popmenu2").then((res) => {
      res.data.map((el) => {
        img1.push(el.img);
      });
      this.img1 = img1;
    });
  },
  methods: {
    myselect(e) {
      this.$router.push({
        path: `/qhxsfirst?id=${e.target.parentNode.dataset.cookid}`,
      });
    },

    liuxing() {
      this.$router.push({
        path: `/caidan/centerpop`,
      });
    },
  },
};
</script>

<style scoped="scoped">
.popmenu {
  width: 300px;
  height: 900px;
  position: absolute;
  right: 21px;
  top: 851px;
  overflow: hidden;
}
.newText {
  font-size: 20px;
  font-weight: 700;
  color: #c0ae7d;
}
.all {
  color: #dd3915;
  position: absolute;
  left: 100px;
  top: 5px;
  cursor: pointer;
}
.all:hover {
  background-color: #dd3915;
  color: white;
}
.popbox {
  width: 300px;
  height: 852px;
  /* background-color: blueviolet; */
}
.pbox {
  width: 298px;
  height: 198px;
  margin-top: 10px;
  margin-bottom: 20px;
  cursor: pointer;
  border: 1px solid #f3f3f3;
}
.pbox:hover {
  opacity: 0.8;
  color: orangered;
}
.pbox img {
  width: 298px;
  height: 140px;
}
.pbox .title1 {
  font-size: 16px;
  text-align: center;
  line-height: 60px;
}
</style>